<?php

namespace app\api\controller;

use app\common\service\Attachment as AttachmentService;
use think\Request;

/**
 * 上传接口
 * Class Attachment
 * @package app\app\controller\v1
 * @author 黄柱 <ihuangzhu@gmail.com>
 */
class Attachment extends Base
{

    /**
     * @var AttachmentService|null 文件业务类
     */
    protected $attachmentService = null;


    /**
     * 上传图片
     * @throws \think\Exception
     */
    public function uploadImage()
    {
       $this->attachmentService = new AttachmentService();
        // 临时取消执行时间限制
        set_time_limit(0);

        // 获取文件
        $file = $this->request->file('file');

        // 开始上传
        $this->attachmentService->uploadImage($file);

        list($this->code, $this->msg, $this->data) = [
            $this->attachmentService->status,
            $this->attachmentService->message,
            $this->attachmentService->data
        ];
    }
    

}